/**
 * Copyright 2017 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * 
 */
package com.netflix.conductor.client.sample;

import com.netflix.conductor.client.worker.Worker;
import com.netflix.conductor.common.metadata.tasks.Task;
import com.netflix.conductor.common.metadata.tasks.TaskResult;
import com.netflix.conductor.common.metadata.tasks.TaskResult.Status;

/**
 * @author Viren
 * 
 */
public class SampleWorker implements Worker {

	private String taskDefName;
	
	public SampleWorker(String taskDefName) {
		this.taskDefName = taskDefName;
	}
	
	@Override
	public String getTaskDefName() {
		return taskDefName;
	}

	@Override
	public TaskResult execute(Task task) {
		
		System.out.printf("Executing %s%n", taskDefName);
		
		TaskResult result = new TaskResult(task);
		result.setStatus(Status.COMPLETED);
		
		//Register the output of the task
		result.getOutputData().put("outputKey1", "value");
		result.getOutputData().put("oddEven", 1);
		result.getOutputData().put("mod", 4);
		
		return result;
	}

}
